package com.ltkj.system.api.factory;

import com.ltkj.common.core.domain.R;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.system.api.RemoteOrderService;
import com.ltkj.system.api.domain.AppletOrderDetailVo;
import com.ltkj.system.api.domain.OrderDetailQueryDTO;
import com.ltkj.system.api.domain.TicOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 订单
 * 
 * @author ruoyi
 */
@Component
public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteOrderFallbackFactory.class);

    @Override
    public RemoteOrderService create(Throwable throwable)
    {
        log.error("订单服务调用失败:{}", throwable.getMessage());
        return new RemoteOrderService()
        {
            @Override
            public R<TicOrder> getWxPayInfo(Long orderId) {
                return R.fail(("获取订单信息失败" + throwable.getMessage()));
            }

            @Override
            public R<TicOrder> orderPayDetail(String wxOrdernum) {
                return R.fail(("获取订单信息失败" + throwable.getMessage()));
            }
            @Override
            public R<TicOrder> orderPayOrderIdDetail(Long orderId) {
                return R.fail(("获取订单信息失败" + throwable.getMessage()));
            }
            @Override
            public AjaxResult orderBack(Long orderId) {
                return AjaxResult.error(("退款后退还库存及修改状态失败" + throwable.getMessage()));
            }
            @Override
            public AjaxResult refundOrderStatus(Long orderId) {
                return AjaxResult.error(("退款申请修改修改状态失败" + throwable.getMessage()));
            }

            @Override
            public R<List<AppletOrderDetailVo>> queryOrderDetail(OrderDetailQueryDTO queryDTO) {
                return R.fail("查询订单详情失败" + throwable.getMessage());
            }

        };
    }
}
